//
//  OMNoLoginView.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/17.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMNoLoginView.h"

@implementation OMNoLoginView {
    UIImageView *_imageView;
    UILabel *_label;
    UIButton *_button;
}

- (instancetype)init
{
    self = [super init];
    [self configure];
    return self;
}

- (void)setMessage:(NSString *)message
{
    _message = message;
    _label.text = message;
}

- (void)configure
{
    self.backgroundColor = HEXCOLOR(@"#F9F9F9");
    _imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"ic_order_list_nologin"]];
    [self addSubview:_imageView];

    _label = [UILabel new];
    _label.textColor = HEXCOLOR(@"#686868");
    _label.font = SM_CFont(30);
    _label.text = @"小主，还没登录看不了订单呢";
    [self addSubview:_label];

    _button = [UIButton new];
    [_button setBackgroundImage:[UIImage imageWithColor:SM_sangouColor] forState:UIControlStateNormal];
    [_button setTitle:@"登录" forState:UIControlStateNormal];
    [_button setTitleColor:SM_blackColor forState:UIControlStateNormal];
    _button.layer.cornerRadius = 4;
    _button.titleLabel.font = SM_CFont(34);
    _button.clipsToBounds = true;
    [[_button rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        [Navigator showLoginViewIfUnLogin];
    }];
    [self addSubview:_button];


    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.bottom.equalTo(self.mas_centerY).offset(SM_SIZE(-80));
    }];

    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(_imageView.mas_bottom).offset(SM_SIZE(30));
    }];

    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(self.mas_centerY).offset(SM_SIZE(90));
        make.width.equalTo(@(SM_SIZE(250)));
        make.height.equalTo(@(SM_SIZE(80)));
    }];
}

@end
